<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>for</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .bord{
            border: 1px dashed #ee2602;
            width: 90%;
            margin: 20px auto;
        }
        .title{
            font-size: 20px;
            font-weight: bold;
            margin: 20px;
        }
        .introduce{
            font-size: 16px;
            margin: 0 0 20px 50px;
        }
        .red{
            color: red;
        }
    </style>
    <script>
        window.onload = function () {
            document.getElementById('a').onclick = function () {
                var x;
                var mynum = new Array()
                mynum[0] = "1";
                mynum[1] = "2";
                mynum[2] = "3";

                for (x in mynum)
                {
                    alert(mynum[x]);
                }
            }
        };
    </script>
</head>
<body>
<div class="bord">
    <div class="title">for</div>
    <div class="introduce">
        for循环可以将代码块执行指定的次数。<br/>
        <pre>
           for (三个条件)
            {
                 在此执行代码
            }
        </pre>
    </div>
</div>
<div class="bord">
    <div class="title">演示效果</div>
    <div class="introduce">
        <p>循环遍历数组1,2,3 ，并打印出来</p><br/>
        <button id="a">点击</button>
    </div>
</div>
<div class="bord">
    <div class="title">代码</div>
    <div class="introduce">
        <pre>
        &lt;script&gt;
            window.onload = function () {
            document.getElementById('a').onclick = function () {
                var x;
                var mynum = new Array()
                mynum[0] = "a";
                mynum[1] = "b";
                mynum[2] = "c";

                for (x in mycars)
                {
                    alert(mycars[x]);
                }
            }
        };
        &lt;/script&gt;

        &lt;p&gt;循环遍历数组a,b,c ，并打印出来&lt;/p&gt;
        &lt;button id="a" &gt;点击&lt;/button&gt;
            </pre>
    </div>
</div>
</body>
</html>